#!/bin/sh

IP_RANGE='172.17.0'

echo "scan network in $IP_RANGE.0/24"
# 清空之前的ip数据
: > ip.txt
for ip in {1..254}
do
    echo -en "$IP_RANGE.$ip \t ... "
    ping -c 3 $IP_RANGE.$ip 2>&1 >:
    if [ $? == 1 ];then
        echo "ok"
        echo $IP_RANGE.$ip >> ip.txt
    else
        echo "error, used!"
    fi
done